﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;

namespace GeneralStore
{
    #region Entities
    [Table("Product")]
    public partial class Product {
        [Key]
        public string ProductId { get; set; }

        [Required]
        public string Name { get; set; }

        [Required(ErrorMessage = "{0} is required")]
        [Range(9999, 999999999999, ErrorMessage = "price must be between {1} and {2}")]
        public decimal ListPrice { get; set; }

        [Required(ErrorMessage = "{0} is required")]
        [Range(9999, 999999999999, ErrorMessage = "price must be between {1} and {2}")]
        public decimal DealPrice { get; set; }

        [Display(Name = "album art url")]
        [StringLength(1024, ErrorMessage = "maxlength = 1024")]
        public List<string> ProductArtUrls { get; set; }

        [DataType(DataType.MultilineText)]
        public string Content { get; set; }

        [DataType(DataType.MultilineText)]
        public string Description { get; set; }

        [Display(Name = "Category")]
        public string CategoryId { get; set; }

        [Display(Name = "Brand")]
        public string BrandId { get; set; }

        public virtual Brand Brand { get; set; }
        public virtual Category Category { get; set; }
        public virtual ICollection<OrderDetail> OrderDetails { get; set; }
    }

    [Table("Brand")]
    public partial class Brand {
        [Key]
        public string BrandId { get; set; }
        public string Name { get; set; }

        public virtual ICollection<Product> Products { get; set; }
    }

    [Table("Category")]
    public partial class Category {
        [Key]
        public string CategoryId { get; set; }
        public string Name { get; set; }

        public virtual ICollection<Product> Products { get; set; }
    }

    [Table("OrderDetail")]
    public partial class OrderDetail {
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int OrderDetailId { get; set; }
        public int OrderId { get; set; }
        public string ProductId { get; set; }
        public int Quantity { get; set; }
        public decimal UnitPrice { get; set; }

        public virtual Product Product { get; set; }
        public virtual Order Order { get; set; }
    }

    [Table("Order")]
    public partial class Order
    {
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [ScaffoldColumn(false)]
        public int OrderId { get; set; }

        [ScaffoldColumn(false)]
        public string Username { get; set; }

        //[Required(ErrorMessage = "First Name is required")]
        //[Display(Name = "First Name")]
        //[StringLength(160)]
        //public string FirstName { get; set; }

        //[Required(ErrorMessage = "Last Name is required")]
        //[Display(Name = "Last Name")]
        //[StringLength(160)]
        //public string LastName { get; set; }

        //[Required(ErrorMessage = "Address is required")]
        //[StringLength(70)]
        //public string Address { get; set; }

        //[Required(ErrorMessage = "City is required")]
        //[StringLength(40)]
        //public string City { get; set; }

        //[Required(ErrorMessage = "State is required")]
        //[StringLength(40)]
        //public string State { get; set; }

        //[Required(ErrorMessage = "Postal Code is required")]
        //[Display(Name = "Postal Code")]
        //[StringLength(10)]
        //public string PostalCode { get; set; }

        //[Required(ErrorMessage = "Country is required")]
        //[StringLength(40)]
        //public string Country { get; set; }

        [Required(ErrorMessage = "Phone is required")]
        [StringLength(24)]
        public string Phone { get; set; }

        [Required(ErrorMessage = "Email Address is required")]
        [Display(Name = "Email Address")]
        [RegularExpression(@"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}",
            ErrorMessage = "Email is is not valid.")]
        [DataType(DataType.EmailAddress)]
        public string Email { get; set; }

        [ScaffoldColumn(false)]
        public decimal Total { get; set; }

        [ScaffoldColumn(false)]
        public DateTime OrderDate { get; set; }

        public virtual ICollection<OrderDetail> OderDetails { get; set; }
    }

    //cart details ...
    [Table("Cart")]
    public class Cart
    {
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int RecordId { get; set; }
        public string CartId { get; set; }
        public string ProductId { get; set; }
        public int Count { get; set; }
        public DateTime DateCreated { get; set; }

        public virtual Product Product { get; set; }
    }
    #endregion
    
}